/*
 * @Author: yanjikun
 * @Date: 2022-06-06 09:58:50
 * @LastEditors: yanjikun
 * @LastEditTime: 2022-06-06 15:33:27
 * @Description: file content
 */

const { path } = require('@vuepress/utils')
const navbar = require('./config/navbar')
const sidebar = require('./config/sidebar')
const { defaultTheme } = require('@vuepress/theme-default')
const demoblockPlugin = require('vuepress-plugin-demoblock-plus')
const { registerComponentsPlugin } = require('@vuepress/plugin-register-components')
const { viteBundler } = require('@vuepress/bundler-vite')
const vueJsx = require('@vitejs/plugin-vue-jsx')
module.exports = {
  // 站点配置
  lang: 'zh-CN',
  title: 'UI-LIB',
  description: '组件库',
  head: [
    // 注入到当前页面的 HTML <head> 中的标签
    [
      'link',
      {
        rel: 'icon',
        href: '/img/logo.png',
      },
    ], // 增加一个自定义的 favicon(网页标签的图标)
  ],
  // 主题和它的配置
  theme: defaultTheme({
    logo: '/img/logo.png',
    navbar,
    sidebar,
    sidebarDepth: 2, // 侧边栏显示2级
  }),
  plugins: [
    demoblockPlugin({}),
    registerComponentsPlugin({
      componentsDir: path.resolve(__dirname, '../../src/components'),
      getComponentName: (name) => {
        return name.split('/').at(-1).replace('.vue', '')
      },
    }),
  ],
  bundler: viteBundler({
    viteOptions: {
      resolve: {
        alias: {
          '@': path.resolve(__dirname, '../../src'),
        },
        mainFields: ['module'],
      },
      plugins: [vueJsx()],
    },
    vuePluginOptions: {},
  }),
}
